package cn.yinzhiping.rabbbitmqlearn.topic;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * topic
 * 订阅模式的消费者
 * @author yinzhiping
 */
@Component
public class TopicConsume {
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, //临时队列
                    exchange = @Exchange(name="topics",type = "topic"),  //交换机
                    key = {"user.*","order.#"}
            )
    })
    public void recieveTopic1(String message){
        System.out.println("recieveTopic1："+message);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue, //临时队列
                    exchange = @Exchange(name="topics",type = "topic"),  //交换机
                    key = {"message.*","order.*"}
            )
    })
    public void recieveTopic2(String message){
        System.out.println("recieveTopic2："+message);
    }

}
